<?php
// +----------------------------------------------------------------------
// | BB [ BB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024~2034 https://www.bobahappy.com.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: luowei Team <luowei@bobahappy.com>
// +----------------------------------------------------------------------

namespace app\model\platform;

use crmeb\basic\BaseModel;
use crmeb\traits\ModelTrait;
use think\Model;
<#list selfMethods as value>
use app\model\platform\${value.foreignClass};
</#list>

/**
 * ${tableComment}
 * Class ${tableClass}
 * @package app\model\platform
 */
class ${tableClass} extends BaseModel
{
    use ModelTrait;

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 表名
     * @var string
     */
    protected $name = '${tableName}';

	
	/**
	 * 默认条件查询器
	 * @param Model $query
	 * @param $value
	 */
	public function searchDefaultAttr($query)
	{
	    $query->where(['is_del' =>0]);
	}
	
	/**
	 * 默认条件查询器
	 * @param Model $query
	 * @param $value
	 */
	public function searchIsDelAttr($query)
	{
	    $query->where(['is_del' =>0]);
	}
	
	<#list selfMethods as value>
	/**
	 * ${value.methodName}
	 * @param Model $query
	 * @param $value
	 */
	public function ${value.methodName}()
	{
	    return $this->hasOne(${value.foreignClass}::class, '${value.foreKey}', '${value.selfKey}')->field('*')->bind([
			'${value.selfName}' => '${value.foreName}'
		]);
	}
	</#list>
}
